package com.training.controller;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.training.common.Result;
import com.training.common.model.Menu;
import com.training.common.model.User;
import com.training.service.UserService;
import com.training.service.UserServiceImp;

import java.util.ArrayList;
import java.util.List;

public class WebController extends Controller {

    @Inject(UserServiceImp.class)
    private UserService userService;

    public void index(){
        User user = getSessionAttr("trainingsession");
        set("username",user.getUsername());
        render("/index.html");
    }

    public void home(){
        render("/views/home/index.html");
    }

    public void usermenulist(){
        User user = getSessionAttr("trainingsession");
        List<Menu> menuList = userService.getMenu(user.getRoleId());
        Result result = new Result();
        result.setData(menuList);
        renderJson(result);
    }
}
